package 树.前中后序遍历;

import 树.递归.TreeNode;

import java.util.ArrayList;
import java.util.List;

public class 二叉树的后序遍历_145 {
    List<Integer> list = new ArrayList<>();

    public List<Integer> postorderTraversal(TreeNode root) {
        if (root == null) {
            return list;
        }
        help(root);

        return list;
    }

    public void help(TreeNode root) {
        if (root == null) {
            return;
        }

        help(root.left);
        help(root.right);
        list.add(root.val);
    }
}
